﻿<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Start</title>

    <!-- Bootstrap -->
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<link href="bootstrap/css/style.css" rel="stylesheet">
	<script type="text/javascript">
		function time() {
		   var today = new Date();
		   var weekday=new Array(7);
		   weekday[0]="Sonntag";
		   weekday[1]="Montag";
		   weekday[2]="Dienstag";
		   weekday[3]="Mittwoch";
		   weekday[4]="Donnerstag";
		   weekday[5]="Freitag";
		   weekday[6]="Samstag";
		   var day = weekday[today.getDay()]; 
		   var dd = today.getDate();
		   var mm = today.getMonth()+1; //January is 0!
		   var yyyy = today.getFullYear();
		   var h=today.getHours();
		   var m=today.getMinutes();
		   var s=today.getSeconds();
		   m=checkTime(m);
		   s=checkTime(s);
		   nowTime = h+":"+m+":"+s;
		   if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} today = day+', '+ dd+'-'+mm+'-'+yyyy;

		   tmp='<span class="date">'+today+' | '+nowTime+'</span>';

		   document.getElementById("clock").innerHTML=tmp;

		   clocktime=setTimeout("time()","1000","JavaScript");
		   function checkTime(i)
		   {
			  if(i<10){
			 i="0" + i;
			  }
			  return i;
		   }
		}
	</script>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
	<body onload= "time()">
		<br><br>
		<div class= "container">
			<div class= "jumbotron" style = "background-color: #341256;">
				<h1 style = "color: white;"> <div class= "page-header"> Nam Bộ Restaurant </div></h1>
				<p class= "text-left" style = "color: white;">Offenbacher Landstr 336, 60599 Frankfurt am Main</p>
				<!--<p class= "text-right" style = "color: white;"><?php 
					//date_default_timezone_set('Europe/Berlin');
					//echo "Heute:". date("d-m-Y"). " - Uhr: ". date("H:i"); ?>
				</p>-->
				<!--uhr erstellen-->
				<p  id  ="clock"class= "text-right" style = "color: white;"></p>
			</div>
			<div class="jumbotron" style = "background-color: #341256; color:white;">
				<h1 style = "color: white;" class= "text-center"> Kassensystem </h1>
				<!-- php login Code-->
				<?php
					global $message; 
					if (isset($_SESSION['kid'])){
						 unset($_SESSION['kid']);
					}
					if (isset($_POST['login'])){
						$kid = $pwd= $message ="";
						if($_POST['kid']== NULL || $_POST['pwd']== NULL){
							$message = "entweder KellnerID oder Pasword leer";
						}
						else {
							$kid = $_POST['kid'];
							$pwd = $_POST['pwd'];
						
							//connect DB
							require_once("db/connectDB.php");
							
							//query
							$sql="select * from kellner where kid='".$kid."' and password='".$pwd."'";
							$query=mysql_query($sql);
							// if empty query
							if(mysql_num_rows($query) == 0){
							    $message = "Kein Kellner gefunden";
							}
							//else
							else{
							   $row=mysql_fetch_array($query);
							   session_start();
							   $_SESSION['kid'] = $row['kid'];
							   	require_once('login.php');  
							}
						}
					}

				?>
				
				<!-- form-->
				
				<form class="form-horizontal" role="form" action = "startseite.php" method = "POST"> 
				  <div class="form-group">
					<label class="col-sm-2 control-label">Kellner</label>
					<div class="col-sm-10">
					  <input type="username"  name = "kid" class="form-control" id="inputEmail3" placeholder="KellnerID">
					</div>
				  </div>
				  <div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
					<div class="col-sm-10">
					  <input type="password" name = "pwd" class="form-control" id="inputPassword3" placeholder="Password">
					</div>
				  </div>
				  <center>
					<p><?php echo $message ?></p>
					<button type="submit" name = "login" class="btn btn-success btn-lg ">Anmelden</button>
					
				  </center>
				</form>
					
				<!-- -->
			</div>
		</div>
		<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
		<!-- Include all compiled plugins (below), or include individual files as needed -->
		<script src="bootstrap/js/bootstrap.min.js"></script>
		
	</body>
</html>